﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PDX.Validation
{
    /// <summary>
    /// A bindable model of a property's validity, suitable to be placed in an
    /// <see cref="IPropertyModel"/>'s <see cref="PropertyModelAspectCollection"/>.
    /// </summary>
    public class ValidationModel : INPC
    {
        string message;
        /// <summary>
        /// Gets or sets the validation message.
        /// </summary>
        /// <value>
        /// The message.
        /// </value>
        public string Message
        {
            get { return message; }
            set
            {
                if (message != value)
                {
                    message = value;
                    OnPropertyChanged("Message");
                    OnPropertyChanged("HasMessage");
                }
            }
        }

        /// <summary>
        /// Gets a value indicating whether this instance has a <see cref="Message"/>.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if this instance has a <see cref="Message"/>; otherwise, <c>false</c>.
        /// </value>
        public bool HasMessage
        {
            get
            {
                return !string.IsNullOrEmpty(Message);
            }
        }
    }
}
